package offer;

/**
 * 剑指 Offer 16. 数值的整数次方
 */
public class MyPow {
    public double myPow(double x, int n) {
        double v = 1;
        if (n >= 0) {
            for (int i = 0; i < n; i++) {
                v = v * x;
            }
        } else {
            for (int i = 0; i < (-n); i++) {
                v = v * (1 / x);
            }
        }

        return v;
    }
}
